
struct ListNode* removeElements(struct ListNode* head, int val){

  if(head==NULL)
  {
      return false;
  }
  while(head!=NULL&&head->val==val)
  {
      struct ListNode* tmp=head;
      head=head->next;
      free(tmp);
  }
  struct ListNode* p=head;
  while(p!=NULL&&p->next!=NULL)
  {
      if(p->next->val==val)
      {
              struct ListNode* q=p->next;
              p->next=q->next;
              free(q);
      }
      else
      p=p->next;
  }
  return head;
}